from functools import *
from toolz.curried import *
from languagetools import *
from importlib import reload
from timeit import timeit
import operator

# mano
import delfi
import pickler
import article_ns
import languagetools

import numpy as np
import pandas as pd
from scipy import stats, integrate

import matplotlib
matplotlib.use('Qt5Agg')
import matplotlib.pyplot as plt
import seaborn as sns

"""
df = pd.DataFrame(articles)
#body_features = df['body'].apply(lambda b: pd.Series(article_ns.features(b)))
body_features = df['body'].apply(lambda b: pipe( dict(body=b), article_ns.features, pd.Series ))
X = pd.concat([body_features, df[['gid', 'category_chain']]],axis=1)

outly_factor = lambda X: np.abs(X - X.mean()) / X.std()

#sns.distplot(X.sents_in_para[outly_factor(X.sents_in_para) < 5], hist=True, bins=30); sns.plt.show(block=False)
lambda X: sns.distplot(X[outly_factor(X) < 5], hist=True, bins=30);

sns.plt.show(block=False)

pipe( body_features, lambda X: X[outly_factor(X) < 3], lambda X: X.std() / X.mean(), lambda X: X.sort_values()  )

"""
